package com.qubuyer.core.http

/**
 * Author: linwg
 * Time: 2021/2/4 0004
 * Description:
 */
class HttpResult<T> : IHttpResult<T> {
    var data: T? = null
    var code: Int = HttpStatusCode.SUCCESS
    var time: Long = 0L
    var msg: String? = null

    override fun data(): T? {
        return data
    }

    override fun code(): Int {
        return code
    }

    override fun msg(): String? {
        return msg
    }

    fun isTokenException(): Boolean {
        return when (code) {
            HttpStatusCode.LOGIN_OVERDUE,
            HttpStatusCode.TOKEN_OVERDUE,
            HttpStatusCode.REQUIRE_LOGIN,
            HttpStatusCode.TOKEN_NOT_EXIST,
            HttpStatusCode.TOKEN_OVER_TIME,
            HttpStatusCode.TOKEN_ERROR,
            HttpStatusCode.ACCOUNT_NOT_EXIST,
            -> true
            else -> false
        }
    }
}